import React, { Component } from 'react'

import {getDatas} from '../../../utils/tools';

import RecomeCourseService from '../../../services/recomcourse'
import {RECOM_COURSE_TH} from '../../../config/table_config'
import ListTitle from '../../../components/common/ListTitle';
import TableHead from '../../../components/common/TableHead'


import './index.scss'

const recomeCourseService = new RecomeCourseService();

export default class RecomeCourse extends Component {
    constructor(props){
        super(props);
        this.state={
            title:'推荐课程管理',
            recomCourseData:[]
        }
    }
    onStatusClick(cid,index){}
    async getRecomCourseData(){
        const result = await recomeCourseService.getRecomCourseData(),
        errorCode = result.error_code,
        data = result.data,
        {history} = this.props;
        
        getDatas(errorCode,data,history,()=>{
          this.setState({
            recomCourseData:data
          })
          
        })
       
    }
   componentDidMount(){
       this.getRecomCourseData();
   }
    render() {
        const {title,thData,courseData,fieldData} = this.state;
        return (
            <div className="list-container">
               <ListTitle title={title} onRefreshData={this.getRecomCourseData.bind(this)} ></ListTitle>
               <table className="list-table">
               <TableHead thData={RECOM_COURSE_TH} ></TableHead>
              
               <TableBody recomCourseData = {recomCourseData} 
                
               
                onStatusClick = {this.onStatusClick.bind(this)}
               ></TableBody>
               </table>
            </div>
        )
    }
}
